package com.mgface.framework.jsengine;

import java.io.File;
import java.io.FileReader;

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class JSEngine {
	
	public static void main(String[] args) throws Exception {
		ScriptEngineManager engineManager = new ScriptEngineManager();
		ScriptEngine engine = engineManager.getEngineByName("nashorn");
		Bindings bindings = engine.createBindings();
		bindings.put("username", "wyux");
		Object result = engine.eval(new FileReader(new File("D:/1.js")),bindings);
		System.out.println(result);
	}

}
